home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj0287.arc / SETFREQ.C < prev    next >
Text File  |  1986-12-16  |  475b  |  18 lines

  1. /* 
  2.  *    setfreq -- sets PC's tone generator to run 
  3.  *    continuously at the specified frequency 
  4.  */ 
  5. #include <conio.h> 
  6. #include "timer.h" 
  7.  
  8. void 
  9. setfreq(f) 
  10. unsigned f;    /* frequency in Hertz (approximate) */ 
  11.     unsigned divisor = TIMER_CLK / f; 
  12.  
  13.     outp(TIMER_CTRL, TIMER_PREP);       /* prepare timer */ 
  14.     outp(TIMER_COUNT, (divisor & 0xFF));   /* low byte of divisor */ 
  15.     outp(TIMER_COUNT, (divisor >> 8));       /* high byte of divisor */ 
  16.